import { createApp, nextTick } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import routes from './route.config'
// import RightNav from './components/right-nav'
// import MainFooter from './components/footer'
// import MainHeader from './components/header'
// import SideNav from './components/side-nav'
// import FooterNav from './components/footer-nav'

import App from './app.vue'


const app = createApp(App)

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

app.use(router)

router.isReady().then(() => {
  router.afterEach(async route => {
    await nextTick()
    const data = title[route.meta.lang]
    for (let val in data) {
      if (new RegExp('^' + val, 'g').test(route.name)) {
        document.title = data[val]
        return
      }
    }
    document.title = 'Element'
    // ga('send', 'event', 'PageView', route.name)
  })
})

app.mount('#app')
